#ifndef _STRAWGUI_COMPONENT_RECT_H_
#define _STRAWGUI_COMPONENT_RECT_H_

#ifdef _EDITOR
#include "sRTTIObject.h"
#endif
#include "sGUIObject.h"
#include "sMath.h"
#include "sComponentRectInstance.h"

namespace sgui
{
namespace res
{


class sComponentRect : public sGUIObject
#ifdef _EDITOR
	, public rtti::sObject
#endif
{
public:

	typedef enum 
	{
		COMPONENT_RECT_FRAME = 0,
		COMPONENT_RECT_TEXT,
		COMPONENT_RECT_TOUCH_ZONE,
        COMPONENT_RECT_EDITABLE_TEXT,

		COMPONENT_RECT_COUNT
	} EComponentRectType;

	static sComponentRect* CreateComponentRect(EComponentRectType type, sGUI& gui);
	
private:
	typedef sComponentRect* (*COMPONENT_RECT_CALLBACK)(sGUI& gui);

	static const COMPONENT_RECT_CALLBACK COMPONENT_RECT_GENERATOR[COMPONENT_RECT_COUNT];

protected:
	math::sRectsf					m_rect;
	bool							m_clipRect;
	sComponentAlign					m_align;
public:
	void setClipRect(const bool& value) { m_clipRect = value; }
	const bool& getClipRect() const { return m_clipRect; }

	math::sRectsf& getRect();
	const math::sRectsf& getRect() const;

	sComponentAlign& getAlign();
	const sComponentAlign& getAlign() const;
		
	void load(const db::Record &file);
	void save(db::Record &file) const;
	void clear();

#ifdef _EDITOR
	void exportRTTI(rtti::sInfoList& list);
#endif
    virtual const EComponentRectType getClass() const = 0;
	virtual inst::sComponentRectInstance* getInstance(inst::sComponentInstance& instanceFor, s32 id) const = 0;
	
	sComponentRect(sGUI& gui);
};

};
};

#endif